package com.example.demo.domain;

import java.util.Calendar;

/**
 * @author shiwq
 * @date 2021/10/25 11:07
 * @describe
 */
public class Sso {
    private String Domain;
    private int expired;
    private String makeTime;
    private String privateKey;
    private String requestURL;
    private String ssoKey;
    private String username;

    public Sso() {
    }

    private String getCurrentTime() {
        Calendar cal = Calendar.getInstance();
        if (this.getExpired() > 0) {
            cal.add(12, this.getExpired());
        }

        String year = (new Integer(cal.get(1))).toString();
        String month = (new Integer(cal.get(2) + 1)).toString();
        String day = (new Integer(cal.get(5))).toString();
        String hour = (new Integer(cal.get(11))).toString();
        String minute = (new Integer(cal.get(12))).toString();
        String second = (new Integer(cal.get(13))).toString();
        if (month.length() == 1) {
            month = "0" + month;
        }

        if (day.length() == 1) {
            day = "0" + day;
        }

        if (hour.length() == 1) {
            hour = "0" + hour;
        }

        if (minute.length() == 1) {
            minute = "0" + minute;
        }

        if (second.length() == 1) {
            second = "0" + second;
        }

        String date = "";
        date = year + month + day + hour + minute + second;
        return date;
    }

    public String getDomain() {
        return this.Domain;
    }

    public int getExpired() {
        return this.expired;
    }

    public String getMakeTime() {
        if (this.makeTime == null) {
            this.initMakeTime();
        }

        return this.makeTime;
    }

    public String getPrivateKey() {
        return this.privateKey;
    }

    public String getRequestURL() {
        return this.requestURL;
    }

    public String getSsoKey() {
        return this.ssoKey;
    }

    public String getUsername() {
        return this.username;
    }

    private void initMakeTime() {
        this.makeTime = this.getCurrentTime();
    }

    public void setDomain(String Domain) {
        this.Domain = Domain;
    }

    public void setExpired(int expired) {
        this.expired = expired;
    }

    public void setMakeTime(String makeTime) {
        this.makeTime = makeTime;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public void setRequestURL(String requestURL) {
        this.requestURL = requestURL;
    }

    public void setSsoKey(String ssoKey) {
        this.ssoKey = ssoKey;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
